<?php defined('IN_ADMIN') or exit('No permission resources.');?>
<?php include $this->admin_tpl('header', 'admin');?>

<h3 style="padding-left: 20px;padding-top: 10px">
	<?=$data['real_name']?>——关联资源
	<a href="?m=talent&c=manage&a=init&talent_type=<?php echo $_GET['talent_type']?>&menuid=<?php echo $_GET['menuid']?>" style="font-size:14px;color: #0000FF"><em>返回上一级</em></a>
</h3>

<div class="subnav">
	<div class="content-menu ib-a blue line-x">
		<a href="?m=resource_asso&c=manage&a=moter_record&source_type=4&talent_id=<?=$talent_id?>&talent_type=<?php echo $_GET['talent_type']?>&menuid=<?php echo $_GET['menuid']?>"><em>履历</em></a>
		<span>|</span>
		<a href="?m=resource_asso&c=manage&a=init&source_type=1&talent_id=<?=$talent_id?>&talent_type=<?php echo $_GET['talent_type']?>&menuid=<?php echo $_GET['menuid']?>"><em>资讯</em></a>
		<span>|</span>
		<a href="?m=resource_asso&c=manage&a=init&source_type=2&talent_id=<?=$talent_id?>&talent_type=<?php echo $_GET['talent_type']?>&menuid=<?php echo $_GET['menuid']?>"> <em>视频</em></a>
		<span>|</span>
		<a href="?m=resource_asso&c=manage&a=init&source_type=3&talent_id=<?=$talent_id?>&talent_type=<?php echo $_GET['talent_type']?>&menuid=<?php echo $_GET['menuid']?>"><em>图片集</em></a>
		<span>|</span>
		<a href="./index.php?m=resource_asso&c=video&a=init&talent_id=<?=$talent_id?>&talent_type=<?php echo $_GET['talent_type']?>&menuid=<?php echo $_GET['menuid']?>" class="on"><em>视频集</em></a>


	</div>
</div>

<div class="pad-lr-10">

	<div id="searchid" style="">
		<form name="searchform" action="" method="get" >
			<input type="hidden" value="<?php echo ROUTE_M;?>" name="m">
			<input type="hidden" value="<?php echo ROUTE_C;?>" name="c">
			<input type="hidden" value="<?php echo ROUTE_A;?>" name="a">

			<input type="hidden" value="1" name="search">
			<input type="hidden" value="<?=$talent_id?>" name="talent_id">
			<input type="hidden" value="<?=$id?>" name="id">
			<input type="hidden" value="<?php echo $pc_hash;?>" name="pc_hash">
			<table width="100%" cellspacing="0" class="search-form">
				<tbody>
				<tr>
					<td>

						<button type="button" style="float:right;margin-right:20px;margin-top:10px;" onclick="showAdd()" ><em>添加视频</em></button>
						<button type="button" style="float:right;margin-right:20px;margin-top:10px;" onclick="showSelect()" ><em>选择视频</em></button>
						<span style="clear: both"></span>
						<script>
							function showAdd(){
								window.top.art.dialog({
										id: 'add',
										iframe: '?m=resource_asso&c=video&a=addVideo&talent_id=<?=$talent_id?>&id=<?=$id?>',
										title: '添加视频',
										width: '900',
										height: '500',
										lock: true
									},
									function() {
										var d = window.top.art.dialog({
											id: 'add'
										}).data.iframe;
										var form = d.document.getElementById('dosubmit');
										form.click();
										return false;
									},
									function() {
										window.top.art.dialog({
											id: 'add'
										}).close()
									});
							}
							function  showSelect(){
								window.top.art.dialog({
										id: 'select',
										iframe: '?m=resource_asso&c=video&a=bindView&id=<?=$id?>',
										title: '选择视频',
										width: '900',
										height: '500',
										lock: true
									},
									function() {
										var d = window.top.art.dialog({
											id: 'select'
										}).data.iframe;
										var relation = d.document.getElementById('relation');


										if(relation.value!=""){
											$.ajax({
												type:"get",
												url:"?m=resource_asso&c=video&a=bindAction&id=<?=$id?>&relation="+relation.value+"&pc_hash=<?php echo $_SESSION['pc_hash'];?>",
												dataType: "json",
												success:function(data){
													if(data['status']){
														window.top.art.dialog({
															id: 'select'
														}).close()
														window.location.reload();
													}else{
														alert(data['msg']);
														return false;
													}
												}
											})
										}else{
											return true;
										}

									},
									function() {
										window.top.art.dialog({
											id: 'select'
										}).close()
									});
							}
						</script>


						<div class="explain-col">
							<?php echo L('title');?>：<input name="title" type="text" value="<?php echo $_GET['title']?>" class="input-text" />
							<input type="submit" name="search" class="button" value="<?php echo L('search');?>" />
						</div>
					</td>
				</tr>
				</tbody>
			</table>
		</form>
	</div>

	<form name="myform" id="myform" action="" method="post" >
		<div class="table-list">
			<table width="100%">
				<thead>
				<tr>
					<th width="16"><input type="checkbox" value="" id="check_box" onclick="selectall('ids[]');"></th>

					<th><?php echo "名称";?></th>
					<th><?php echo "描述";?></th>
					<th><?php echo "视频地址";?></th>
					<th><?php echo "封面图";?></th>
					<th><?php echo "上次编辑者";?></th>
					<th><?php echo "绑定者";?></th>
					<th width="200"><?php echo L('operations_manage');?></th>
				</tr>
				</thead>
				<tbody>
				<?php
				if(is_array($sourceinfo)) {

					foreach ($sourceinfo as $k=> $r) {
						?>
						<tr>
							<td align="center"><input class="inputcheckbox " name="ids[]" value="<?php echo $r['cid'];?>" type="checkbox"></td>
							<td align='center' ><?php echo $r['title'];?></td>
							<td align='center' ><?php if(!empty($r['description'])){echo str_cut($r['description'],60);}else{echo "<font color='red'>未设置</font>";}?></td>
							<td align='center' ><?php if(!empty($r['video_link'])){echo $r['video_link'];}else{echo "<font color='red'>未设置</font>";}?></td>
							<td align='center' ><?php if(!empty($r['image_cover'])){echo "<img src=".$r['image_cover']." height=60>";}else{echo "<font color='red'>未设置</font>";}?></td>
							<td align='center' ><?php echo $adminInfo[$r['updated_by']];?></td>	
							<td align='center' ><?php echo $adminInfo[$r['supdated_by']];?></td>	

							<td align='center'><a href="?m=resource_asso&c=video&a=delVideo&id=<?php echo $r['cid']?>" onClick="return confirm('<?php echo L('confirm', array('message' => new_addslashes($r['title'])))?>')"><?php echo L('del_bind')?></a></td>

						</tr>
					<?php }
				}
				?>
				</tbody>
			</table>
			<div class="btn"><label for="check_box"><?php echo L('selected_all');?>/<?php echo L('cancel');?></label>
				<input type="hidden" value="<?php echo $pc_hash;?>" name="pc_hash">
				<input type="button" class="button" value="<?php echo L('del_bind');?>" onclick="myform.action='?m=resource_asso&c=video&a=deleteAll&dosubmit=1&steps=<?php echo $steps;?>';return confirm_delete()"/>
			</div>
			<div id="pages"><?php echo $pages;?></div>
		</div>
	</form>
</div>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>cookie.js"></script>
<script type="text/javascript">

	function confirm_delete(){
		if(confirm('<?php echo L('manage_info_delete');?>')) $('#myform').submit();
	}


</script>
<script type="text/javascript">
	setcookie('refersh_time', 0);
	function refersh_window() {
		var refersh_time = getcookie('refersh_time');
		if(refersh_time==1) {
			window.location.reload();
		}
	}
	setInterval("refersh_window()", 1500);
</script>
</body>
</html>